/*
 * Packet.h
 *
 *  Created on: Jul 7, 2009
 *      Author: lfor
 */

#ifndef PACKET_H_
#define PACKET_H_

// Errors
#define PACKET_OK 					0
#define PACKET_ERROR 				-1
#define PACKET_INVALID_PARAM 		1
#define PACKET_NOT_ENOUGH_BUFFER 	2

// Sizes
#define MAX_BUFF_SIZE 1024

#define MAX_NAME_SIZE 50
#define MAX_PARAM_SIZE 256
#define MAX_RETURN_SIZE 256
#define MAX_ERROR_SIZE 256

// Status
typedef enum
{
	NONE = 0,
	CLOSE,
	CALL,
	RECALL,
	OK,
	ERROR,
	ONGOING,
	LIST
} StatusType;

// Packets
typedef struct
{
	StatusType  Status;
	char Function[MAX_NAME_SIZE];
	char Params[MAX_PARAM_SIZE];
	char Returns[MAX_RETURN_SIZE];
	char Errors[MAX_ERROR_SIZE];
	int DataLength;
	char * Data;
} PacketType;

int ParseBuffer(char * Buffer, int Size, PacketType * Packet);
int FillBuffer(PacketType Packet, char * Buffer, int * Size);



#endif /* PACKET_H_ */
